import {ElMessage, ElMessageBox} from "element-plus";

/**
 * 封装一个消息提示的函数
 *
 * @param msg
 * @param type
 */
export const showMessage = (msg, type) => {
    ElMessage({
        showClose: true, //是否显示关闭按钮
        message: msg, //消息文字
        type: type, //消息类型: 'success' | 'warning' | 'info' | 'error'
    })
}

/**
 * 获取前端的token名称
 *
 * @returns {string}
 */
export const getTokenName = () => {
    return "dlykToken";
}

/**
 * 清理sessionStorage和localStorage中的token
 */
export const clearToken = () => {
    window.sessionStorage.removeItem(getTokenName());
    window.localStorage.removeItem(getTokenName())
}

export const confirmMessage = (msg) => {
    return ElMessageBox.confirm(
        msg,
        '系统提醒',
        {
            confirmButtonText: '确 定',
            cancelButtonText: '取 消',
            type: 'warning',
        }
    )
}